//
//  TWTweetReponseModel.m
//  TWHomework-WeChat
//
//  Created by wzb on 2019/11/13.
//  Copyright © 2019 WZB. All rights reserved.
//

#import "TWTweet.h"
#import "Define.h"
#import "TWUserInfo.h"

@implementation TWTweet

+ (NSDictionary *)modelContainerPropertyGenericClass {
    return @{ @"comments" : [TWTweetComment class] };
}

@end


@implementation TWTweetComment

- (CGFloat)cellHeightWithPreferWidth:(CGFloat)preferWidth
{
    if (!_cellHeight) {
        _cellHeight = [self sizeWithPreferWidth:preferWidth font:kComTextFont text:[NSString stringWithFormat:@"%@:%@", self.sender.username, self.content]];
    }
    return _cellHeight;
}

- (CGFloat)sizeWithPreferWidth:(CGFloat)width font:(UIFont *)font text:(NSString *)text
{
    NSDictionary *attributes = @{ NSFontAttributeName : font };
    CGRect rect = [text boundingRectWithSize:CGSizeMake(width, MAXFLOAT) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:attributes context:nil];
    return ceilf(CGRectGetHeight(rect));
}

@end
